<?php if(!defined('ARCH_ROOT_PATH')) exit;
/**
 *	Architect Framework
 *
 *	Architect Framework is a light weight object oriented web applications framework written for PHP 5.1.4 and later that provide the tools to develop and deploy a website or application fast and with as little code as possible.
 *
 *	@author Robin Grass, <hello@coffinboy.se>
 *	@link http://architect.kodlabbet.net
 *	@license http://www.opensource.org/licenses/gpl-3.0.html GNU General Public License (v. 3)
 */

/**
 *	Architect_Session
 *
 *	A wrapper class for sessions.
 *
 *	@package Utilities
 *	@version 1.0
 *	@author Robin Grass, <hello@coffinboy.se>
 */
class Architect_Session {

	/**
	 *	@var string $prefix
	 */
	protected $prefix = 'arch_';
	
	/**
	 *	open
	 *
	 *	@return bool true
	 */
	public function open() {
		session_start();
		return true;
	}
	
	/**
	 *	read
	 *
	 *	@param string|int $id
	 *
	 *	@return mixed
	 */
	public function read($id) {
		if($_SESSION && array_key_exists($this->prefix . $id, $_SESSION))
			return $_SESSION[$this->prefix . $id];
	return null;
	}
	
	/**
	 *	write
	 *
	 *	@param string|int $id
	 *	@param mixed $data
	 */
	public function write($id, $data) {
		$_SESSION[$this->prefix . $id] = $data;
	}
	
	/**
	 *	delete
	 *
	 *	@param string|int $id
	 *
	 *	@return bool
	 */
	public function delete($id) {
		if($_SESSION && array_key_exists($this->prefix . $id, $_SESSION)) {
			unset($_SESSION[$this->prefix . $id]);
			return true;
		}
	return false;
	}

}
?>